local chushan = fk.CreateSkill {
  name = "water_chushan",
  tags={Skill.Wake},
}

Fk:loadTranslationTable{
  ["water_chushan"] = "出山",
  [":water_chushan"] = [[觉醒技，准备阶段你选择一名其他角色其获得一个【弑】标记，拥有【弑】标记的角色每轮失去一点体力，
  然后你增加1点体力上限并将体力值回复至体力上限，并对全场目标造成一次闪电判定，然后你失去【出山】。]],
  ["#water_chushan_target"] = "出山：请选择一名其他角色获得【弑】标记",
  ["@@water_shi"] = "弑",
}
--【出山】准备阶段阶段你选择一名其他角色其获得一个【弑】标记，拥有【弑】标记的角色每轮失去一点体力流失(三回合后失效），
--然后你增加1点体力上限并将体力值回复至体力上限，并对全场目标造成一次闪电判定，然后你失去【出山】。并重置(夺权）技能。
chushan:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self.name)  and player:usedSkillTimes(self.name,Player.HistoryGame)<1 and
    player.phase==Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = room:askForChoosePlayers(player, 1, 1, self.name, true, "#water_chushan_target")
    if #targets > 0 then
      room:setPlayerMark(room:getPlayerById(targets[1]), "@@water_shi", 1)
    end
    room:changeMaxHp(player, 3)
    room:recover({
      who = player,
      num = player.maxHp - player.hp,
      recoverBy = player,
      skillName = self.name,
    })
    for _, p in ipairs(room:getAlivePlayers()) do
      local pattern = ".|2~9|spade"
      local judge = {
        who = p,
        reason = "lightning",
        pattern = pattern,
      }
      room:judge(judge)
      if judge.card:matchPattern(pattern) then
        room:damage {
          to = p,
          damage = 3,
          damageType = fk.ThunderDamage,
          skillName =chushan.name,
        }
      end
    end
  end,
})


chushan:addEffect(fk.RoundStart, {
  anim_type = "offensive",
  can_refresh = function(self, event, target, player, data)
    return player:getMark("@@water_shi")>0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player,1)
  end,
})

return chushan 